基于docker部署glusterfs集群
参考：https://github.com/gluster/gluster-containers

准备3个节点，每个节点执行以下命令运行glusterfs容器：

docker run -d --name gluster   -v /etc/glusterfs:/etc/glusterfs:z   -v /var/lib/glusterd:/var/lib/glusterd:z   -v /var/log/glusterfs:/var/log/glusterfs:z   -v /sys/fs/cgroup:/sys/fs/cgroup:ro   -v /dev/:/dev --restart=always   -v /glusterfs/:/glusterfs   --privileged=true --net=host   gluster/gluster-centos

挂载目录说明：

/etc/glusterfs：持久化gluster configuration
/var/lib/glusterd：持久化gluster metadata
/var/log/glusterfs：持久化gluster logs
/glusterfs： 创建volume
查看容器运行状态

[root@gluster1 ~]# docker ps -a
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS               NAMES
988c802d8e58        gluster/gluster-centos   "/usr/local/bin/upda…"   3 minutes ago       Up 3 minutes                            gluster
1
2
3
查看glusterd进程运行状态

安装客户端
yum install -y glusterfs glusterfs-fuse


[root@localhost ~]# docker exec -it gluster bash

[root@localhost /]# systemctl status glusterd
● glusterd.service - GlusterFS, a clustered file-system server
   Loaded: loaded (/usr/lib/systemd/system/glusterd.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2020-05-29 18:00:48 UTC; 5min ago
     Docs: man:glusterd(8)
  Process: 78 ExecStart=/usr/sbin/glusterd -p /var/run/glusterd.pid --log-level   (code=exited, status=0/SUCCESS)
 Main PID: 79 (glusterd)
   CGroup: /system.slice/docker-8cd538665c8c4c0293b9299d1baa37ce99b59df6d08e18568cb72b4556cc49d3.scope/system.slice/glusterd.service
           └─79 /usr/sbin/glusterd -p /var/run/glusterd.pid --log-level INFO

May 29 18:00:47 localhost.localdomain systemd[1]: Starting GlusterFS, a clustered file-system server...
May 29 18:00:48 localhost.localdomain systemd[1]: Started GlusterFS, a clustered file-system server.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
查看系统版本和glusterfs版本

[root@localhost /]# cat /etc/redhat-release 
CentOS Linux release 7.7.1908 (Core)

[root@localhost /]# gluster --version
glusterfs 7.1
1
2
3
4
5
进入任一容器执行添加集群操作，ip地址为节点IP：

[root@localhost /]# gluster peer probe 192.168.93.61
peer probe: success. 
[root@localhost /]# gluster peer probe 192.168.93.62
peer probe: success.
1
2
3
4
创建volume

gluster volume create vol_distributed transport tcp   192.168.93.60:/glusterfs/vol1   192.168.93.61:/glusterfs/vol1   192.168.93.62:/glusterfs/vol1 force
1
2
3
4
启动volume

[root@localhost /]#  gluster volume start vol_distributed 
volume start: vol_distributed: success
1
2
查看voluem信息

[root@localhost /]# gluster volume info 
 
Volume Name: vol_distributed
Type: Distribute
Volume ID: 79dd669f-4600-49ff-8dba-6374646dce2b
Status: Started
Snapshot Count: 0
Number of Bricks: 3
Transport-type: tcp
Bricks:
Brick1: 192.168.93.60:/glusterfs/vol1
Brick2: 192.168.93.61:/glusterfs/vol1
Brick3: 192.168.93.62:/glusterfs/vol1
Options Reconfigured:
transport.address-family: inet
storage.fips-mode-rchecksum: on
nfs.disable: on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
客户端节点：

yum install -y centos-release-gluster
yum install -y glusterfs glusterfs-fuse
1
2
挂载卷到本地

mount -t glusterfs 10.130.70.12:/vol_distributed /mnt
1
写入数据验证

touch /mnt/file{1..9}.txt

[root@localhost ~]# ls /glusterfs/vol1/
789  file1.txt  file2.txt  file3.txt  file5.txt  file7.txt  file9.txt
1
2
3
4
参考：https://blog.csdn.net/wylfengyujiancheng/article/details/90576192
————————————————
版权声明：本文为CSDN博主「freesharer」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。
原文链接：https://blog.csdn.net/networken/article/details/106431137
